package com.yz.controller;

import com.yz.kafka.ConsumerProducer;

import com.yz.pojo.KafkaConstants;
import com.yz.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wlf
 * @data: 2021-10-18
 * @Description
 */
@RestController
@RequestMapping("/kafka")
public class KafkaController {

    @Autowired
    private ConsumerProducer consumerProducer;

    @RequestMapping("/producer")
    public R setConsumerProducer(String data) {
       try {
           consumerProducer.send(KafkaConstants.WYZ,data);
           return R.ok();
       }catch (Exception e){
            return R.error();
       }
    }
}
